<%@ Language=VBScript%>
 <%
	Session("FormName")="F10"
%>
<!--#include file=..\checkSession.inc-->
<!--#include file=..\getFormName.inc-->
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>New Page 2</title>
</head>
<!--#include file=..\jvGrid.inc-->
<!--#include file=..\vbFunction.inc-->
<!--#include file="..\pageSelected.inc"-->
<!--#include file=..\funTab.inc-->
<%			
	bnhaplt=Request("bnhaplt")
	if bnhaplt <> "" then
		Session("bnhaplientuc")=bnhaplt
	end if
	Set ClsFun=server.CreateObject("Vinalines.ClsFunction")	
	Dim bLink 
	mode=Request("mode")
	bComm=Request("bComm")
	bMa=Request("bMa")
	bMacu=Request("bMacu")
	if bComm="detail" then				
		sSQL="Select * from canbo where macanbo Like '"& bMa &"' "
		Set RecDL=server.CreateObject("ADODB.Recordset")
		RecDL.CursorType=3
		RecDL.CacheSize=5
		RecDL.Open sSQL,Conn
		
		if RecDL.RecordCount then	
			Session("bmauser")=RecDL("macanbo")
			Session("btenuser")=RecDL("hovaten")
			bHoten=RecDL("hovaten")
			bNgaysinh=RecDL("ngaysinh")
			bUsername=RecDL("username")
			bUsernamecu=RecDL("username")
			bPassword=RecDL("password")
			bNguoisua=RecDL("nguoisua")	
			bConfirm=request("password")
			bChucdanh=RecDL("chucvu")
			RSex=RecDL("Gioitinh")
			bEmail=RecDL("email")
			bSoNT=RecDL("SoNT")
			'bLoaiCB=RecDL("loai")
			'Loaitim=RecDL("Loaitim")
			bsearch=request("bsearch")
			bLock=RecDL("lock")	
			bMaDonVi=RecDL("MaDonVi")		

			'Thudientu
			bMailBox=RecDL("MailBox")
			bMailBoxcu=RecDL("MailBox")
			bMailPassword=RecDL("mailpassword")
			bMailConfirm=request("mailpassword")	

		end if
		RecDL.Close
		Set RecDL=nothing
	else
		bHoten=Request("bHoten")
		bNgaysinh=Request("bNgaysinh")
		bUsername=request("bUsername")
		bUsernamecu=request("bUsernamecu")
		bPassword=request("bPassword")
		bNguoisua=Request("bNguoisua")	
		bConfirm=request("bConfirm")
		bChucdanh=request("bChucdanh")
		RSex=Request("RSex")
		bEmail=request("bEmail")
		bSoNT=request("bSoNT")
		bLoaiCB=request("bLoaiCB")
		Loaitim=request("Loaitim")
		bsearch=request("bsearch")
		bLock=Request("bLock")
		
		bMaDonVi=Request("bMaDonVi")

		'Thudientu
		bMailBox=request("bMailBox")
		bMailBoxcu=request("bMailBoxcu")
		bMailPassword=request("bMailPassword")
		bMailConfirm=request("bMailConfirm")

		Session("bmauser")=Request("bMa")
		Session("btenuser")=Request("bHoten")
	end if
	if request("CommLock")="lock"	 then
		sSQL="Update canbo set Lock=1 where macanbo like '"& bMa &"'"
		Conn.Execute sSQL
	end if
	if request("CommLock")="unlock"	 then
		sSQL="Update canbo set Lock=0 where macanbo like '"& bMa &"'"
		Conn.Execute sSQL
	end if
	Dim bTempComm
	dim bMsg	
	if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then
	Select Case bComm
		Case "add"
			bMa=Ucase(bMa)
			if not KTMa(bMa,bComm) then
				if not KTUserName(bUsername,bComm) then	
					bPassword=ClsFun.Mahoa(bPassword)
					if trim(bNgaysinh)="" then						
						sSQL="Insert into canbo(macanbo,hovaten,ngaysinh,username,password,chucvu,email,nguoisua,Gioitinh,lock,SoNT,madonvi,mailbox,mailpassword)values('"& ClsFun.ModiString(bMa) &"','"& ClsFun.ModiString(bHoten) &"',NULL,'"& ClsFun.ModiString(busername) &"','"& bPassword &"','"& ClsFun.ModiString(bChucdanh) &"','"& ClsFun.ModiString(bEmail) &"','"& Session("bHoten") &"',"& RSex &",0,'"& ClsFun.ModiString(bSoNT) &"','"& ClsFun.ModiString(bMaDonVi) &"','"& ClsFun.ModiString(bmailbox) &"','"& bMailPassword &"')"
					else
						sSQL="Insert into canbo(macanbo,hovaten,ngaysinh,username,password,chucvu,email,nguoisua,Gioitinh,lock,SoNT,madonvi,mailbox,mailpassword)values('"& ClsFun.ModiString(bMa) &"','"& ClsFun.ModiString(bHoten) &"','"& ClsFun.SaveDate(bNgaysinh) &"','"& ClsFun.ModiString(busername) &"','"& bPassword &"','"& ClsFun.ModiString(bChucdanh) &"','"& ClsFun.ModiString(bEmail) &"','"& Session("bHoten") &"',"& RSex &",0,'"& ClsFun.ModiString(bSoNT) &"','"& ClsFun.ModiString(bMaDonVi) &"','"& ClsFun.ModiString(bmailbox) &"','"& bMailPassword &"')"
					end if
					Conn.Execute sSQL
					if bloaiCB <> "skhongnhom" and bloaiCB <> "snhieunhom" then
						sSQL="insert into canbo_nhomquyen(nhom_id,macanbo) values ('"& ClsFun.ModiString(bLoaiCB) &"','"& ClsFun.ModiString(bMa) &"')"
						Conn.Execute sSQL
					end if
					'Ghi nhan Ai da login thanh cong						
					bTrangthailog=1
					bHoten=Session("bHoten")
					bNgaygio=cstr(Date()) &" "& cstr(Time())
					bChucnang="C&#7853;p nh&#7853;t c&#225;n b&#7897;"
					bIDTailieu=""
					bDongtac="Th&#234;m m&#7899;i"
					sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
					&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"','"& bTrangthailog &"')"
					Conn.Execute sSQL					
				else
					Msg="Username " +bma + "&#273;&#227; c&#243; ng&#432;&#7901;i s&#7917; d&#7909;ng"
					bMsg="username"
				end if
			else
				Msg="M&#227; c&#225;n b&#7897; n&#224;y &#273;&#227; t&#7891;n t&#7841;i"
				bMsg="ma"
			end if
		case "delete"	
			set RecKT=server.CreateObject("ADODB.Recordset")
			RecKT.CursorType=3
			RecKT.CacheSize=5
			ssql="Select macanbo from canbo_nhom where macanbo like '"& ClsFun.ModiString(bma) &"'"
			RecKT.Open ssql,Conn
			if RecKT.RecordCount<=0 then
				set RecKTQ=server.CreateObject("ADODB.Recordset")
				RecKTQ.CursorType=3
				RecKTQ.CacheSize=5
				ssql="Select macanbo from Quyen where macanbo = '"& ClsFun.ModiString(bma) &"'"
				RecKTQ.Open ssql,Conn
				if RecKTQ.RecordCount<=0 then
					RecKTQ.Close
					set RecKTQ=nothing
					set RecKTVV=server.CreateObject("ADODB.Recordset")
					RecKTVV.CursorType=3
					RecKTVV.CacheSize=5
					sSQL="Select nguoitao from Vuviec where nguoitao = '"& ClsFun.ModiString(bma) &"'"
					RecKTVV.Open sSQL,Conn
					if RecKTVV.RecordCount<=0 then
						RecKTVV.Close
						set RecKTVV=nothing
						set RecKTDT=server.CreateObject("ADODB.Recordset")
						RecKTDT.CursorType=3
						RecKTDT.CacheSize=5
						sSQL="Select nguoitao from vtduthao where nguoitao = '"& ClsFun.ModiString(bma) &"'"
						RecKTDT.Open sSQL,Conn
						if RecKTDT.RecordCount<=0 then
							RecKTDT.Close
							set RecKTDT=nothing
							set RecKTNB=server.CreateObject("ADODB.Recordset")
							RecKTNB.CursorType=3
							RecKTNB.CacheSize=5
							sSQL="Select nguoiky from vtnoibo where nguoiky = '"& ClsFun.ModiString(bma) &"'"
							RecKTNB.Open sSQL,Conn
							if RecKTNB.RecordCount<=0 then	
								RecKTNB.Close
								set RecKTFlow=nothing	
								set RecKTFlow=server.CreateObject("ADODB.Recordset")
								RecKTFlow.CursorType=3
								RecKTFlow.CacheSize=5
								sSQL="Select Nguoitao from Workflow where nguoitao = '"& ClsFun.ModiString(bma) &"'"
								RecKTFlow.Open sSQL,Conn
								if RecKTFlow.RecordCount<=0 then										
									RecKTFlow.Close
									set RecKTFlow=nothing
									set RecKTFlowNode=server.CreateObject("ADODB.Recordset")
									RecKTFlowNode.CursorType=3
									RecKTFlowNode.CacheSize=5
									sSQL="Select Nguoixuly from flownode where Nguoixuly = '"& ClsFun.ModiString(bma) &"'"
									RecKTFlowNode.Open sSQL,Conn
									if RecKTFlowNode.RecordCount<=0 then																				
										RecKTFlowNode.Close
										Set RecKTFlowNode=nothing
										
										set RecKTDC=server.CreateObject("ADODB.Recordset")
										RecKTDC.CursorType=3
										RecKTDC.CacheSize=5
										sSQL="Select nguoiphutrach from diachiluutru where nguoiphutrach = '"& ClsFun.ModiString(bma) &"'"
										RecKTDC.Open sSQL,Conn
										if RecKTDC.RecordCount<=0 then
											RecKTDC.Close
											Set RecKTDC=nothing										
											
											set RecKTWCB=server.CreateObject("ADODB.Recordset")
											RecKTWCB.CursorType=3
											RecKTWCB.CacheSize=5
											sSQL="Select IDUser from workflow_Canbo where IDUser = '"& ClsFun.ModiString(bma) &"'"
											RecKTWCB.Open sSQL,Conn
											if RecKTWCB.RecordCount<=0 then
												RecKTWCB.Close
												set RecKTWCB=nothing												
												sSQL="Delete from canbo Where macanbo Like '"& ClsFun.ModiString(bMa) &"'"
												Conn.Execute sSQL	
												'xoa nhom_id thuoc macabo trong bang canbo_nhomquyen
												sSQL="delete from canbo_nhomquyen where macanbo like '"& ClsFun.ModiString(bMa) &"'"
												Conn.Execute sSQL
												'xoa quyen thuoc bang canbo_dsquyen
												sSQL="delete from canbo_dsquyen where macanbo like '"& ClsFun.ModiString(bMa) &"'"
												Conn.Execute sSQL
												'Ghi nhan Ai da login thanh cong						
												bTrangthailog=1
												bHoten=Session("bHoten")
												bNgaygio=cstr(Date()) &" "& cstr(Time())
												bChucnang="C&#7853;p nh&#7853;t c&#225;n b&#7897;"
												bIDTailieu=""
												bDongtac="Xo&#225;"
												sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
													&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"','"& bTrangthailog &"')"
												if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then
													Conn.Execute sSQL
												end if
											else
												RecKTWCB.Close
												Set RecKTWCB=nothing
												Msg="Cán bộ đang nẳm trong danh sách theo dõi Workflow nên không thể xóa được !"
											end if
										else
											RecKTDC.Close
											Set RecKTDC=nothing
											Msg="C&#225;n b&#7897; &#273;ang li&#234;n k&#7871;t (&#208;&#7883;a ch&#7881; l&#432;u tr&#7919;) kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c!"
										end if
									else
										RecKTFlowNode.Close
										Set RecKTFlowNode=nothing
										Msg="C&#225;n b&#7897; &#273;ang li&#234;n k&#7871;t (D&#242;ng c&#244;ng vi&#7879;c) kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c!"
									end if
								else
									RecKTFlow.Close
									set RecKTFlow=nothing
									Msg="C&#225;n b&#7897; &#273;ang li&#234;n k&#7871;t(D&#242;ng c&#244;ng vi&#7879;c) kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c!"									
								end if
							else
								RecKTNB.Close
								set RecKTNB=nothing	
								Msg="C&#225;n b&#7897; &#273;ang li&#234;n k&#7871;t(N&#7897;i b&#7897;) kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c !"
							end if
						else
							RecKTDT.Close
							set RecKTDT=nothing	
							Msg="C&#225;n b&#7897; &#273;ang li&#234;n k&#7871;t(D&#7921; th&#7843;o) kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c !"
						end if
					else
						RecKTVV.Close
						set RecKTVV=nothing	
						Msg="C&#225;n b&#7897; &#273;ang li&#234;n k&#7871;t(V&#7909; vi&#7879;c) kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c !"
					end if					
				else
					RecKTQ.Close
					set RecKTQ=nothing
					Msg="C&#225;n b&#7897; &#273;ang li&#234;n k&#7871;t(Quy&#7873;n) kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c !"
				end if
				
			else
				Msg="C&#225;n b&#7897; &#273;ang thu&#7897;c nh&#243;m kh&#244;ng th&#7875; xo&#225; &#273;&#432;&#7907;c !"
				bMsg="xoa"
			end if
			RecKT.Close
			set RecKT=nothing		
		case "edit"
			bMa=Ucase(bMa)
			set RecKT=server.CreateObject("ADODB.Recordset")
			RecKT.CursorType=3
			RecKT.CacheSize=5
			'Kiem tra quan he va sua
			ssql="Select macanbo from canbo_nhom where macanbo like '"& ClsFun.ModiString(bmacu) &"'"
			RecKT.Open ssql,Conn
			on error resume next
			Conn.BeginTrans
			if RecKT.RecordCount<=0 then
				if not KTMa(bMa,"edit") then
					if not KTUserName(bUsername,bComm) then												
						if bUsernamecu=Session("UName") then
							Session("UName")=busername
							Session("bHoten")=bHoten
							Session("Password")=bPassword
						end if						
						bPassword=ClsFun.Mahoa(bPassword)
						if trim(bNgaysinh)="" then
	 						sSQL="Update canbo set Hovaten='"& (bHoten)_
										&"',ngaysinh=NULL,Username='"& ClsFun.ModiString(busername) _
										&"',Macanbo='"& ClsFun.ModiString(bMa) _
										&"',Password='"& bPassword _
										&"',Email='"& ClsFun.ModiString(bEmail) _
										&"',Chucvu='"& ClsFun.ModiString(bChucdanh) _
										&"',Gioitinh="& RSex &",Nguoisua='"& Session("bHoten") _
										&"',SoNT='"& ClsFun.ModiString(bSoNT) _
										&"',madonvi='"& ClsFun.ModiString(bMaDonVi) _
										&"',Mailbox='"& ClsFun.ModiString(bMailbox) _
										&"',mailpassword='"& bMailPassword _
										&"' Where macanbo Like '" & ClsFun.ModiString(bMacu) & "'"							
						else
	 						sSQL="Update canbo set Hovaten='"& (bHoten) _
										&"',ngaysinh='"& ClsFun.SaveDate(bNgaysinh) _
										&"',Username='"& ClsFun.ModiString(busername) _
										&"',Macanbo='"& ClsFun.ModiString(bMa) _
										&"',Password='"& bPassword _
										&"',Email='"& ClsFun.ModiString(bEmail) _
										&"',Chucvu='"& ClsFun.ModiString(bChucdanh) _
										&"',Gioitinh="& RSex &",Nguoisua='"& Session("bHoten") _										
										&"',SoNT='"& ClsFun.ModiString(bSoNT) _
										&"',madonvi='"& ClsFun.ModiString(bMaDonVi) _
										&"',Mailbox='"& ClsFun.ModiString(bMailbox) _
										&"',mailpassword='"& bMailPassword _
										&"' Where macanbo Like '" & ClsFun.ModiString(bMacu) & "'"
						end if						
						Conn.Execute sSQL
						sSQL="Select * from canbo_nhomquyen where macanbo Like '"& bMacu &"' "
						Set RecNQ=server.CreateObject("ADODB.Recordset")
						RecNQ.CursorType=3
						RecNQ.CacheSize=5
						RecNQ.Open sSQL,Conn
						if RecNQ.RecordCount > 1 and (bloaiCB <>"snhieunhom" and bloaiCB <>"skhongnhom") then
							sSQL="delete canbo_nhomquyen where macanbo like '" & ClsFun.ModiString(bMacu) & "'"
							Conn.Execute sSQL
							sSQL="insert into canbo_nhomquyen(nhom_id,macanbo) values('"& ClsFun.ModiString(bLoaiCB)&"','" & ClsFun.ModiString(bMa) & "')"
							Conn.Execute sSQL
						else
							if RecNQ.RecordCount >= 1 and bloaiCB = "skhongnhom" then
								sSQL="delete canbo_nhomquyen where macanbo like '" & ClsFun.ModiString(bMacu) & "'"
								Conn.Execute sSQL
							else
								if RecNQ.RecordCount = 1 and (bloaiCB <>"snhieunhom" and bloaiCB <>"skhongnhom") then
									sSQL="delete canbo_nhomquyen where macanbo like '" & ClsFun.ModiString(bMacu) & "'"
									Conn.Execute sSQL
									sSQL="insert into canbo_nhomquyen(nhom_id,macanbo) values('"& ClsFun.ModiString(bLoaiCB)&"','" & ClsFun.ModiString(bMa) & "')"
									Conn.Execute sSQL
								else
									if (RecNQ.RecordCount = 0) and (bloaiCB<>"skhongnhom" and bloaiCB<>"snhieunhom")then
										sSQL="insert into canbo_nhomquyen(nhom_id,macanbo) values('"& ClsFun.ModiString(bLoaiCB)&"','" & ClsFun.ModiString(bMa) & "')"
										Conn.Execute sSQL
									else 
										if RecNQ.RecordCount > 1 and bloaiCB = "snhieunhom" and bMacu <> bMa then
											ssql="select * from canbo_nhomquyen where macanbo like '"& ClsFun.ModiString(bMacu) &"'"
											set RecNhieuMa = server.CreateObject("ADODB.Recordset")
											RecNhieuMa.CursorType=3
											RecNhieuMa.CacheSize=5
											RecNhieuMa.Open ssql,conn
											if not RecNhieuMa.BOF and not RecNhieuMa.EOF then
												RecNhieuMa.MoveFirst
												do while not RecNhieuMa.EOF
													ssql="update canbo_nhomquyen set macanbo='"& ClsFun.ModiString(bMa) &"' where macanbo='"& ClsFun.ModiString(bMacu) &"'"
													Conn.Execute ssql
													RecNhieuMa.MoveNext												
												loop
											end if
											RecNhieuMa.Close
											set RecNhieuMa=nothing
										end if	
									end if
								end if
							end if
						end if						
						RecNQ.Close
						set RecNQ=nothing
						'Session("bHoten")=bHoten
						if len(bMacu)>len(bMa) then
							if instr(1,bMa,bMacu,0)=0 then
								sSQL="Update Quyen set macanbo='"& bMa &"' where macanbo = '"& bMacu &"'"
								Conn.Execute sSQL			
								sSQL="Update vtnoibo set nguoiky='"& bMa &"' where nguoiky = '"& bMacu &"'"
								Conn.Execute sSQL
								sSQL="Update vtduthao set nguoitao='"& bMa &"' where nguoitao = '"& bMacu &"'"
								Conn.Execute sSQL
								sSQL="Update Vuviec set nguoitao='"& bMa &"' where nguoitao = '"& bMacu &"'"
								Conn.Execute sSQL
								sSQL="Update Workflow set nguoitao='"& bMa &"' where nguoitao = '"& bMacu &"'"								
								Conn.Execute sSQL
								sSQL="Update Flownode set nguoixuly='"& bMa &"' where nguoixuly = '"& bMacu &"'"
								Conn.Execute sSQL
								sSQL="Update muontra set MaCB='"& bMa &"' where MaCB = '"& bMacu &"'"
								Conn.Execute sSQL																
								sSQL="Update Workflow_Canbo set IDUser='"& bMa &"' where IDUser = '"& bMacu &"'"
								Conn.Execute sSQL
								if Session("bMaCB")=bMacu then
									Session("bMaCB")=bMa			
								end if
							end if
						else
							if instr(1,bMacu,bMa,0)=0 then
								sSQL="Update Quyen set macanbo='"& bMa &"' where macanbo = '"& bMacu &"'"
								Conn.Execute sSQL			
								sSQL="Update vtnoibo set nguoiky='"& bMa &"' where nguoiky	= '"& bMacu &"'"	
								Conn.Execute sSQL			
								sSQL="Update vtduthao set nguoitao='"& bMa &"' where nguoitao = '"& bMacu &"'"
								Conn.Execute sSQL
								sSQL="Update Vuviec set nguoitao='"& bMa &"' where nguoitao = '"& bMacu &"'"
								Conn.Execute sSQL
								sSQL="Update Workflow set nguoitao='"& bMa &"' where nguoitao = '"& bMacu &"'"								
								Conn.Execute sSQL
								sSQL="Update Flownode set nguoixuly='"& bMa &"' where nguoixuly = '"& bMacu &"'"
								Conn.Execute sSQL
								sSQL="Update muontra set MaCB='"& bMa &"' where MaCB = '"& bMacu &"'"
								Conn.Execute sSQL		
								sSQL="Update Workflow_Canbo set IDUser='"& bMa &"' where IDUser = '"& bMacu &"'"
								Conn.Execute sSQL
								if Session("bMaCB")=bMacu then
									Session("bMaCB")=bMa			
								end if
							end if
						end if						
					else
						Msg="UserName &#273;&#227; c&#243; ng&#432;&#7901;i s&#7917; d&#7909;ng"
						bMsg="username"
					end if
				else
					Msg="Mã cán bộ này đã tồn tại"
					bMsg="ma"
				end if
			else
				if LCase(bMacu)<>Lcase(bma) then
					Msg="M&#227; c&#225;n b&#7897; &#273;ang &#273;&#432;&#7907;c s&#7917; d&#7909;ng kh&#244;ng th&#7875; thay &#273;&#7893;i &#273;&#432;&#7907;c"
					bMsg="used"
				else
					if not KTMa(bMa,"edit") then
						if not KTUserName(bUsername,bComm) then	
							bPassword=ClsFun.Mahoa(bPassword)	
							if bUsernamecu=Session("UName") then
								Session("UName")=busername								
								Session("bHoten")=bHoten
							end if			
							if trim(bNgaysinh)="" then
								sSQL="Update canbo set Hovaten='"& ClsFun.ModiString((bHoten)) _
										&"',ngaysinh=NULL,Username='"& ClsFun.ModiString(busername) _
										&"',Password='"& bPassword _
										&"',Email='"& ClsFun.ModiString(bEmail) _
										&"',Chucvu='"& ClsFun.ModiString(bChucdanh) _
										&"',Gioitinh="& RSex &",Nguoisua='"& Session("bHoten") _
										&"',SoNT='"& ClsFun.ModiString(bSoNT) _
										&"',madonvi='"& ClsFun.ModiString(bMaDonVi) _
										&"',Mailbox='"& ClsFun.ModiString(bMailbox) _
										&"',mailpassword='"& bMailPassword _
										&"' Where macanbo Like '" & ClsFun.ModiString(bMacu) & "'"
							else
								sSQL="Update canbo set Hovaten='"& ClsFun.ModiString((bHoten)) _
											&"',ngaysinh='"& ClsFun.SaveDate(bNgaysinh) _
											&"',Username='"& ClsFun.ModiString(busername) _
											&"',Password='"& bPassword _
											&"',Email='"& ClsFun.ModiString(bEmail) _
											&"',Chucvu='"& ClsFun.ModiString(bChucdanh) _
											&"',Gioitinh="& RSex &",Nguoisua='"& Session("bHoten") _
											&"',SoNT='"& ClsFun.ModiString(bSoNT) _
											&"',madonvi='"& ClsFun.ModiString(bMaDonVi) _
											&"',Mailbox='"& ClsFun.ModiString(bMailbox) _
											&"',mailpassword='"& bMailPassword _
											&"' Where macanbo Like '" & ClsFun.ModiString(bMacu) & "'"

							end if
							Conn.Execute sSQL				
							sSQL="Select * from canbo_nhomquyen where macanbo Like '"& bMacu &"' "
							Set RecNQ=server.CreateObject("ADODB.Recordset")
							RecNQ.CursorType=3
							RecNQ.CacheSize=5
							RecNQ.Open sSQL,Conn
							if RecNQ.RecordCount > 1 and (bloaiCB <>"snhieunhom" and bloaiCB <>"skhongnhom") then
							sSQL="delete canbo_nhomquyen where macanbo like '" & ClsFun.ModiString(bMacu) & "'"
							Conn.Execute sSQL
							sSQL="insert into canbo_nhomquyen(nhom_id,macanbo) values('"& ClsFun.ModiString(bLoaiCB)&"','" & ClsFun.ModiString(bMa) & "')"
							Conn.Execute sSQL
							else
								if RecNQ.RecordCount >= 1 and bloaiCB = "skhongnhom" then
									sSQL="delete canbo_nhomquyen where macanbo like '" & ClsFun.ModiString(bMacu) & "'"
									Conn.Execute sSQL
								else
									if RecNQ.RecordCount = 1 and (bloaiCB <>"snhieunhom" and bloaiCB <>"skhongnhom") then
										sSQL="delete canbo_nhomquyen where macanbo like '" & ClsFun.ModiString(bMacu) & "'"
										Conn.Execute sSQL
										sSQL="insert into canbo_nhomquyen(nhom_id,macanbo) values('"& ClsFun.ModiString(bLoaiCB)&"','" & ClsFun.ModiString(bMa) & "')"
										Conn.Execute sSQL
									else
										if (RecNQ.RecordCount = 0) and (bloaiCB<>"skhongnhom" and bloaiCB<>"snhieunhom")then
											sSQL="insert into canbo_nhomquyen(nhom_id,macanbo) values('"& ClsFun.ModiString(bLoaiCB)&"','" & ClsFun.ModiString(bMa) & "')"
											Conn.Execute sSQL
										else
											if RecNQ.RecordCount > 1 and bloaiCB = "snhieunhom" and bMacu <> bMa then
												ssql="select * from canbo_nhomquyen where macanbo like '"& ClsFun.ModiString(bMacu) &"'"
												set RecNhieuMa = server.CreateObject("ADODB.Recordset")
												RecNhieuMa.CursorType=3
												RecNhieuMa.CacheSize=5
												RecNhieuMa.Open ssql,conn
												if not RecNhieuMa.BOF and not RecNhieuMa.EOF then
													RecNhieuMa.MoveFirst
													do while not RecNhieuMa.EOF
														ssql="update canbo_nhomquyen set macanbo='"& ClsFun.ModiString(bMa) &"' where macanbo='"& ClsFun.ModiString(bMacu) &"'"
														Conn.Execute ssql
														RecNhieuMa.MoveNext												
													loop
												end if
												RecNhieuMa.Close
												set RecNhieuMa=nothing
											end if	
											
										end if
									end if
								end if
							end if
							RecNQ.Close
							set RecNQ=nothing
						else
							Msg="UserName &#273;&#227; c&#243; ng&#432;&#7901;i s&#7917; d&#7909;ng"
							bMsg="username"
						end if
					end if			
				end if
			end if
			if Err.number=0 then
				Conn.CommitTrans
				bTrangthailog=1
			else
				Conn.RollbackTrans
				bTrangthailog=0
			end if
			'Ghi nhan Ai da login thanh cong						
			bTrangthailog=1
			bHoten=Session("bHoten")
			bNgaygio=cstr(Date()) &" "& cstr(Time())
			bChucnang="C&#7853;p nh&#7853;t c&#225;n b&#7897;"
			bIDTailieu=""
			bDongtac="S&#7917;a"
			sSQL="insert into loguser(Tennguoisudung,ngaygio,chucnangdung,dongtac,IDTailieu,Trangthai) Values('"& bHoten _
				&"','"& bNgaygio &"','"& bChucnang &"','"& bDongtac &"','"& bIDTailieu &"','"& bTrangthailog &"')"
			Conn.Execute sSQL
			
			Err.Clear
			RecKT.Close
			set RecKT=nothing				
		'end if
	End Select
	end if
	Set Rec=server.CreateObject("ADODB.Recordset") 
	rec.CursorType = 3
	rec.CacheSize=5
	
	select case request("bComm")
		case "search"	
			if IsRoot(Session("bMaDonVi")) then
				'strDieuKien=" and SUBSTRING(madonvi,5,2) like '00' " 
				strDieuKien=""				
			else
				strDieuKien=" and madonvi like '"& LEFT(Session("bMaDonVi"),4) &"%' "
			end if
			ssql="Select * from canbo where hovaten like '%"& ClsFun.Modistring(bsearch) & "%'" & strDieuKien & " order by stt1,stt2,stt3,ten,hovaten"
		case else
			Loaitim=""
			bsearch=""
			bDieukien=""
			if IsRoot(Session("bMaDonVi")) then
				'strDieuKien=" where SUBSTRING(madonvi,5,2) like '00' " 
				strDieuKien=""
			else
				strDieuKien=" where madonvi like '"& LEFT(Session("bMaDonVi"),4) &"%' "
			end if
			ssql="Select * from canbo " & strDieuKien & " order by stt1,stt2,stt3,ten,hovaten"
	end select
	Dim nRecCount	' Number of records found
	Dim nPageCount	' Number of pages of records we have
	Dim nPage	' Current page number
	nPage=CLng(request("Page"))	
	if nPage="" then nPage=1
	rec.Open ssql,Conn
	if  rec.EOF and rec.BOF then
		nPageCount=0
	end if	
%>
<%if Msg<>"" then%>
	<% if bMsg="xoa" then %>
			<center><font size=2 color=red face=arial><%=Msg%></font></center>
   <%end if%>
  <% if bMsg="ma" then %>
			<center><font size=2 color=red face=arial>M&#227; c&#225;n b&#7897;: <%=bma%> &#273;&#227; t&#7891;n t&#7841;i</font></center>
   <%end if%>
  <% if bMsg="username" then %>
			<center><font size=2 color=red face=arial>Tên đăng nhập: <%=bUsername%> &#273;&#227; t&#7891;n t&#7841;i</font></center>
   <%end if%>
   <% if bMsg="" then %>
			<center><font size=2 color=red face=arial><%=Msg%> </font></center>
   <%end if%>
   <% if bMsg="used" then %>
			<center><font size=2 color=red face=arial><%=Msg%></font></center>
   <%end if%>
<%end if%>
<!--#include file="..\jvfunction.inc"-->
<script language=VBScript runat=server>
	Function KTMa(bValue,loai)
		KTMa=false
		if loai="add" then
			ssql="Select * from canbo where Macanbo like '"& trim(ClsFun.ModiString(bValue)) &"'"
			Set RecTemp=server.CreateObject("ADODB.Recordset") 
			RecTemp.Open ssql,Application("StrConn")
			if (not rectemp.BOF) and (not RecTemp.EOF) then
				KTMa=True
			end if
			set RecTemp=nothing
		end if
		if loai="edit" then
			if Lcase(bMacu)<>Lcase(bValue) then
				ssql="Select * from canbo where Macanbo like '"& trim(ClsFun.ModiString(bValue)) &"'"
				Set RecTemp=server.CreateObject("ADODB.Recordset") 
				RecTemp.Open ssql,Application("StrConn")
				if (not rectemp.BOF) and (not RecTemp.EOF) then
					KTMa=True
				end if
				set RecTemp=nothing
			end if		
		end if
	End function
	Function KTTen(bValue)
		KTTen=false
		ssql="Select * from canbo where Hovaten like '"& trim(ClsFun.ModiString(bValue)) &"'"
		Set RecTemp=server.CreateObject("ADODB.Recordset") 
		RecTemp.Open ssql,Application("StrConn")
		if (not rectemp.BOF) and (not RecTemp.EOF) then
			KTTen=True
		end if
		Set  RecTemp=nothing
	End function	
	Function KTUserName(bValue,loai)
		KTUserName=false
		if loai="add" then
			ssql="Select * from canbo where username like '"& trim(ClsFun.ModiString(bValue)) &"'"
			Set RecTemp=server.CreateObject("ADODB.Recordset") 
			RecTemp.Open ssql,Application("StrConn")
			if (not rectemp.BOF) and (not RecTemp.EOF) then
				KTUserName=True
			end if
			set RecTemp=nothing
		end if
		if loai="edit" then
			if bUsernamecu<>bValue then
				ssql="Select * from canbo where username like '"& trim(ClsFun.ModiString(bValue)) &"'"
				Set RecTemp=server.CreateObject("ADODB.Recordset") 
				RecTemp.Open ssql,Application("StrConn")
				if (not rectemp.BOF) and (not RecTemp.EOF) then
					KTUserName=True
				end if
				set RecTemp=nothing
			end if		
		end if
	End function
	Function Daucach(bItem)
		Dim bValue
		bValue=bItem
		Daucach=false
		if instr(1,bValue," ",vbTextCompare) then
			Daucach=true
		else
			Daucach=false
		end if
	End Function
Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
	Dim strQueryString
	Dim strScript
	Dim intStart
	Dim intEnd
	Dim strRet
	Dim i

	If intPage > intPageCount Then
		intPage = intPageCount
	ElseIf intPage < 1 Then 
		intPage = 1
	End If
	
	If intRecordCount = 0 Then
		'strRet = "No Records Found"
	ElseIf intPageCount = 1 Then
		'strRet = "End Of Hits"
	Else
		For i = 1 To Request.QueryString.Count
			If LCase(Request.QueryString.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
			End If
		Next

		For i = 1 To Request.Form.Count
			If LCase(Request.Form.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
			End If
		Next

		If Len(strQueryString) <> 0 Then
			strQueryString = "?" & Mid(strQueryString, 2) & "&"
		Else
			strQueryString = "?"
		End If

		strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
	
		If intPage <= 10 Then
			intStart = 1
		Else
			If (intPage Mod 10) = 0 Then
				intStart = intPage - 9
			Else
				intStart = intPage - (intPage Mod 10) + 1
			End If
		End If

		intEnd = intStart + 9
		If intEnd > intPageCount Then intEnd = intPageCount
	
		'strRet = "Page " & intPage & " of " & intPageCount & ": "
	
		If intPage > 10 Then 
			strRet = strRet & "<a href=""" & strScript
			strRet = strRet & "page=" & intPage - 10 
			strRet = strRet & """><IMG border=0 SRC=../images/prev.gif></a> "
		End If
	
		For i = intStart To intEnd
			If i = intPage Then
				strRet = strRet & "<b><font color=A90A08>" & i & "</font></b> "
			Else
				strRet = strRet & "<a href=""" & strScript
				strRet = strRet & "page=" & i 
				strRet = strRet & """>" & i & "</a>"
				If i <> intEnd Then strRet = strRet & " "
			End If
		Next
	
		If intPage <> intPageCount and intPageCount > 10 Then
			strRet = strRet & " <a href=""" & strScript
			strRet = strRet & "page=" & intPage + 10 
			strRet = strRet & """><IMG border=0 SRC=../images/next.gif></a> "
		End If
	End If
	
	Paging = strRet
End Function
</script>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function ChangePage() {
	strURL=nhom.page.value;
	window.nhom.target="right";
	window.nhom.action=strURL;
	window.nhom.submit();
}

function SetFocus(){
	if(!nhom.TxtMa.disabled){
		document.nhom.TxtEmail.focus();
	}
	else{
		document.nhom.CmdSearch.focus();
	}
}
function CmdUserNhom_onclick() {
	/*
	if (KTnhap()){
		ma=nhom.TxtMa.value;
		hoten=nhom.TxtHoten.value;
		ngaysinh=nhom.TxtNgaysinh.value;
		username=nhom.TxtUsername.value;
		password=nhom.TxtPassword.value;
		nhomquyen=nhom.CommboLoai.value;
		chucdanh=nhom.CommboChucdanh.value;
		email=nhom.TxtEmail.value;
		macu=nhom.Macu.value;
		usernamecu=nhom.Usernamecu.value;
		bc=nhom.sua.value;
		cp=nhom.cPage.value;
		sont=nhom.TxtSoNT.value;
		
		bMaDonVi='<%=bMaDonVi%>';		
		
		//Thudientu
		mailbox=nhom.TxtMailBox.value;
		mailboxcu=nhom.mailboxcu.value
		mailpassword=nhom.TxtMailPassword.value;
		
			if (bc=="1"){
				b="frmcanbo.asp?Page="+cp+"&bMacu="+macu+"&bUsernamecu="+usernamecu+"&bma="+ma+"&bHoten="+hoten+"&bemail="+email
				b=b+"&bNgaysinh="+ngaysinh+"&bUsername="+username+"&bPassword="+password
				b=b+"&bLoaiCB="+nhomquyen+"&bChucdanh="+chucdanh+"&bSoNT="+sont+"&bMaDonVi="+bMaDonVi
				b=b+"&bMailboxcu="+mailboxcu+"&bMailbox="+mailbox+"&bMailPassword="+mailpassword+"&bComm=edit"
			}
			else
			 {
				b="frmcanbo.asp?Page="+cp+"&bma="+ma+"&bHoten="+hoten+"&bemail="+email
				b=b+"&bNgaysinh="+ngaysinh+"&bUsername="+username+"&bPassword="+password
				b=b+"&bLoaiCB="+nhomquyen+"&bChucdanh="+chucdanh+"&bSoNT="+sont+"&bMaDonVi="+bMaDonVi
				b=b+"&bMailboxcu="+mailboxcu+"&bMailbox="+mailbox+"&bMailPassword="+mailpassword+"&bComm=add"	
			}
			window.nhom.target="right";
			window.nhom.action=b;
			window.nhom.submit();
	}
	*/
	//window.nhom.target="main";
	window.nhom.target="right";
	parent.vbalFrameset.cols = "0,6,*";
	nhom.action="UserNhom/frmUserNhom.asp";
	nhom.submit();
}

function CmdLock_onclick(){
	<%if Session("IsAdmin")=false and bUsername="admin" then%>
		alert("Administrator không cho phép khoá");
		return ;
	<%else%>
		<%if bLock then%>
		nhom.action="frmcanbo.asp?CommLock=unlock&bMa=<%=bMa%>";
		<%else%>
		nhom.action="frmcanbo.asp?CommLock=lock&bMa=<%=bMa%>";
		<%end if%>
		nhom.target="right";
		nhom.submit();
	<%end if%>
}
function KTnhap(){
	if (trim(nhom.TxtMa.value)==""){
		alert("Bạn cần phải nhập mã");
		nhom.TxtMa.focus();
		return false;
	}
	if(daucach(trim(nhom.TxtMa.value))){
		alert("Mã không cho phép chứa ký tự đặc biệt (',space)");
		nhom.TxtMa.focus();
		return false;
	}
	if (nhom.TxtHoten.value==""){
		alert("Bạn cần phải nhập tên");
		nhom.TxtHoten.focus();
		return false;
	}
/*	if (nhom.TxtNgaysinh.value==""){
		alert("Bạn cần phải nhập ngày sinh");
		nhom.TxtNgaysinh.focus();
		return false;
	}
	if (!isDate(nhom.TxtNgaysinh.value)){
		alert("Ngày sinh không hợp lệ");
		nhom.TxtNgaysinh.focus();
		return false;
	}	*/

	if (nhom.TxtNgaysinh.value!=""){
		if (!isDate(nhom.TxtNgaysinh.value)){
			alert("Ngày sinh không hợp lệ");
			nhom.TxtNgaysinh.focus();
			return false;
		}
	}

	if (nhom.TxtUsername.value==""){
		alert("Cho biết tên truy nhập");
		nhom.TxtUsername.focus();
		return false;
	}
	if (daucach(nhom.TxtUsername.value)){
		alert("Tên truy nhập không cho phép chứa ký tự đặc biệt(',space)");
		nhom.TxtUsername.focus();
		return false;
	}
	if (nhom.TxtPassword.value==""){
		alert("Cho biết mật khẩu truy nhập");
		nhom.TxtPassword.focus();
		return false;
	}
	if (daucach(nhom.TxtPassword.value)){
		alert("Mật khẩu không cho phép chứa ký tự đặc biệt(',space)");
		nhom.TxtPassword.focus();
		return false;
	}
/* if (nhom.CommboLoai.value==""){
		alert("Bạn cần phải chọn quyền");
		nhom.CommboLoai.focus();
		return false;
	}
	if (nhom.CommboChucdanh.value==""){
		alert("Bạn cần phải chọn chức danh");
		nhom.CommboChucdanh.focus();
		return false;
	}	*/
	if (nhom.TxtConfirm.value!=nhom.TxtPassword.value){
		alert("Bạn cần phải xác nhận đúng mật khẩu");
		nhom.TxtConfirm.focus();
		return false;
	}

	//Thudientu
	if (nhom.TxtMailBox.value==""){
		alert("Cho biết tên hộp thư ");
		nhom.TxtMailBox.focus();
		return false;
	}
	if (daucach(nhom.TxtMailBox.value)){
		alert("Tên hộp thư không cho phép chứa ký tự đặc biệt(',space)");
		nhom.TxtMailBox.focus();
		return false;
	}
	if (nhom.TxtMailPassword.value==""){
		alert("Cho biết mật khẩu thư");
		nhom.TxtMailPassword.focus();
		return false;
	}
	if (daucach(nhom.TxtMailPassword.value)){
		alert("Mật khẩu thư không cho phép chứa ký tự đặc biệt(',space)");
		nhom.TxtMailPassword.focus();
		return false;
	}
	if (nhom.TxtMailConfirm.value!=nhom.TxtMailPassword.value){
		alert("Bạn cần phải xác nhận đúng mật khẩu thư");
		nhom.TxtMailConfirm.focus();
		return false;
	}
	return true;
}
function CmdAdd_onclick() {
	nhom.TxtMa.value="<%=TaoMa("macanbo","canbo")%>"
	//nhom.TxtMa.value="";
	nhom.TxtHoten.value="";
	nhom.TxtConfirm.value="";
	nhom.TxtEmail.value="";
	nhom.TxtNgaysinh.value="";
	nhom.TxtPassword.value="";
	nhom.TxtUsername.value="";
	//Thu dientu
	nhom.TxtMailPassword.value="";
	nhom.TxtMailBox.value="";	

	nhom.CommboChucdanh.value="";	
	//nhom.CommboLoai.value="";
	nhom.TxtSoNT.value="";
	nhom.CheckAdd.disabled=false;
	nhom.CheckAdd.checked=true;
	cmdenable(false);
	Unlockdata();
	nhom.cmdNhomQuyen.disabled=true;
	nhom.TxtMa.disabled=false;
	nhom.TxtUsername.disabled=false;
	nhom.TxtEmail.focus();
	nhom.sua.value="2";
	}
function cmdenable(bvalue){
	if (bvalue){
		nhom.CmdAdd.disabled= false;
		nhom.CmdDelete.disabled= false;
		nhom.CmdEdit.disabled= false;
		nhom.CmdLock.disabled= false;
		nhom.CmdCancel.disabled= true;
		nhom.CmdOK.disabled= true;	
		nhom.CmdPrint.disabled=false;
		nhom.CmdSearch.disabled=false;
	}
	else {
		nhom.CmdAdd.disabled= true;
		nhom.CmdDelete.disabled= true;
		nhom.CmdEdit.disabled= true;
		nhom.CmdLock.disabled= true;
		nhom.CmdCancel.disabled= false;
		nhom.CmdOK.disabled= false;
		nhom.CmdPrint.disabled=true;
		nhom.CmdSearch.disabled=true;
	}	
	nhom.CmdSearch.value="Tì<u>m</u> kiếm";
}

function CmdCancel_onclick() {
	cmdenable(true);
	nhom.CmdDelete.disabled= true;
	nhom.CmdEdit.disabled= true;
	nhom.CmdLock.disabled=true;
	nhom.cmdNhomQuyen.disabled=true;
	nhom.CheckAdd.checked= false;
	nhom.CheckAdd.disabled= true;
	Lockdata();
	nhom.TxtMa.value="";
	nhom.TxtHoten.value="";
	nhom.TxtConfirm.value="";
	nhom.TxtEmail.value="";
	nhom.TxtNgaysinh.value="";
	nhom.TxtPassword.value="";
	nhom.TxtUsername.value="";
	//nhom.CommboLoai.value="";
	nhom.TxtSoNT.value="";
	nhom.CommboChucdanh.value="";
		window.nhom.target="right";
		window.nhom.action="frmcanbo.asp?bnhaplt=off";
		window.nhom.submit();
}

function Lockdata(){
	nhom.TxtMa.disabled=true;
	nhom.TxtConfirm.disabled=true;
	nhom.TxtHoten.disabled=true;
	nhom.TxtEmail.disabled=true;
	nhom.TxtNgaysinh.disabled=true;
	nhom.TxtPassword.disabled=true;
	nhom.TxtUsername.disabled=true;

	//Thudientu
	nhom.TxtMailPassword.disabled=true;
	nhom.TxtMailBox.disabled=true;	
	nhom.TxtMailConfirm.disabled=true;

	nhom.TxtSoNT.disabled=true;
	nhom.CommboChucdanh.disabled=true;
	nhom.CommboLoai.disabled=true;
	nhom.cmdNhomQuyen.disabled=true;
	nhom.R1.disabled=true;
	nhom.R2.disabled=true;
	nhom.R3.disabled=true;
	nhom.comboDonVi.disabled=true;
}
function Unlockdata(){
<%if Session("IsAdmin")=false then%>
		<%if bUsername="admin" then%>
			nhom.TxtMa.disabled=true;		
			nhom.TxtUsername.disabled=true;
			nhom.TxtConfirm.disabled=true;
			nhom.TxtHoten.disabled=true;
			nhom.TxtEmail.disabled=true;
			nhom.TxtNgaysinh.disabled=true;
			nhom.TxtPassword.disabled=true;
			
			//Thudientu
			nhom.TxtMailPassword.disabled=true;
			nhom.TxtMailBox.disabled=true;	
			nhom.TxtMailConfirm.disabled=true;

			nhom.CommboChucdanh.disabled=true;
			nhom.TxtSoNT.disabled=true;
			nhom.R1.disabled=true;
			nhom.R2.disabled=true;
			nhom.R3.disabled=true;
			nhom.CommboLoai.disabled=true;
			nhom.cmdNhomQuyen.disabled=true;
			nhom.comboDonVi.disabled=true;
		<%else%>
			nhom.TxtConfirm.disabled=false;
			nhom.TxtHoten.disabled=false;
			nhom.TxtEmail.disabled=false;
			nhom.TxtNgaysinh.disabled=false;
			nhom.TxtPassword.disabled=false;

			//Thudientu
			nhom.TxtMailPassword.disabled=false;
			nhom.TxtMailBox.disabled=false;	
			nhom.TxtMailConfirm.disabled=false;

			nhom.CommboChucdanh.disabled=false;
			nhom.TxtSoNT.disabled=false;
			nhom.R1.disabled=false;
			nhom.R2.disabled=false;
			nhom.R3.disabled=false;
			nhom.CommboLoai.disabled=false;
			nhom.cmdNhomQuyen.disabled=false;
			nhom.TxtMa.disabled=false;
			nhom.TxtUsername.disabled=false;
			nhom.comboDonVi.disabled=false;
		<%end if%>
	<%end if%>
	<%if Session("IsAdmin")=true then%>
		<%if bUsername="admin" then%>
			nhom.TxtConfirm.disabled=false;
			nhom.TxtHoten.disabled=false;
			nhom.TxtEmail.disabled=false;
			nhom.TxtNgaysinh.disabled=false;
			nhom.TxtPassword.disabled=false;

			//Thudientu
			nhom.TxtMailPassword.disabled=false;
			nhom.TxtMailBox.disabled=false;	
			nhom.TxtMailConfirm.disabled=false;

			nhom.CommboChucdanh.disabled=false;
			nhom.TxtSoNT.disabled=false;
			nhom.R1.disabled=false;
			nhom.R2.disabled=false;
			nhom.R3.disabled=false;
			nhom.CommboLoai.disabled=false;
			nhom.cmdNhomQuyen.disabled=false;
			nhom.TxtMa.disabled=true;
			nhom.TxtUsername.disabled=true;			
			nhom.comboDonVi.disabled=false;
		<%else%>
			nhom.TxtConfirm.disabled=false;
			nhom.TxtHoten.disabled=false;
			nhom.TxtEmail.disabled=false;
			nhom.TxtNgaysinh.disabled=false;
			nhom.TxtPassword.disabled=false;

			//Thudientu
			nhom.TxtMailPassword.disabled=false;
			nhom.TxtMailBox.disabled=false;	
			nhom.TxtMailConfirm.disabled=false;

			nhom.CommboChucdanh.disabled=false;
			nhom.TxtSoNT.disabled=false;
			nhom.R1.disabled=false;
			nhom.R2.disabled=false;
			nhom.R3.disabled=false;
			nhom.CommboLoai.disabled=false;
			nhom.cmdNhomQuyen.disabled=false;
			nhom.TxtMa.disabled=false;
			nhom.TxtUsername.disabled=false;
			nhom.comboDonVi.disabled=false;
		<%end if%>
	<%end if%>
}


function window_onload() {
}

function CmdExit_onclick() {
}
function CmdDelete_onclick() {
	if (nhom.TxtMa.value==""){
		alert("Chọn thông tin cần xóa");
		return ;
	}
	if (trim(nhom.TxtUsername.value)=="admin"){
		alert("Administrator không cho phép xóa");
		return ;
	}	
	if (trim(nhom.TxtUsername.value)==trim("<%=Session("UName")%>")){
		alert("Không thể xóa chính bạn");
		return ;
	}
	if(!confirm("Bạn có muốn xóa không ?")){
		return false;	
	}	
	ma=nhom.TxtMa.value;
	b="frmcanbo.asp?page="+"<%=npage%>"+"&bma="+ma+"&bComm=delete"
	window.nhom.target="right";
	window.nhom.action=b;
	window.nhom.submit();
}
function CmdEdit_onclick() {
<%if Session("IsAdmin")=false and bUsername="admin" then%>
	alert("Administrator không cho phép sửa");
	return ;
	<%else%>
	if (nhom.TxtMa.value==""){
		alert("Bạn hãy chọn thông tin cần sửa");
		return ;
	}
	cmdenable(false);
	Unlockdata();
	nhom.TxtHoten.focus();
	<%bTempComm="edit"%>
	nhom.sua.value="1";
	nhom.Macu.value=nhom.TxtMa.value;
	nhom.Usernamecu.value=nhom.TxtUsername.value;
	<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then %>	
		<%if len(bPassword)>0 then
				bGiaima=ClsFun.Giaima(bPassword)				
			end if
		%>		
		<%if bComm="detail" then%>
		nhom.TxtPassword.value="<%=bGiaima%>";
		nhom.TxtConfirm.value="<%=bGiaima%>";
		
		//Thudientu
		nhom.TxtMailPassword.value="<%=bMailPassword%>";
		nhom.TxtMailConfirm.value="<%=bMailPassword%>";		
		<%end if%>
	<%end if%>
	//Thudientu
	nhom.mailboxcu.value=nhom.TxtMailBox.value;
<%end if%>
}
function CmdOK_onclick() {
	if (KTnhap()){
		//cmdenable(true);
		//Lockdata();
		
		ma=nhom.TxtMa.value;
		hoten=ChuanHoaTen(nhom.TxtHoten.value);
		ngaysinh=nhom.TxtNgaysinh.value;
		username=nhom.TxtUsername.value;
		password=nhom.TxtPassword.value;
		//loai=nhom.CommboLoai.value;	
		nhomquyen=nhom.CommboLoai.value;
		chucdanh=nhom.CommboChucdanh.value;
		email=nhom.TxtEmail.value;
		macu=nhom.Macu.value
		usernamecu=nhom.Usernamecu.value
		bc=nhom.sua.value
		cp=nhom.cPage.value
		sont=nhom.TxtSoNT.value;
		madonvi=nhom.comboDonVi.value;
		
		//Thudientu
		mailbox=nhom.TxtMailBox.value;
		mailpassword=nhom.TxtMailPassword.value;
		mailboxcu=nhom.mailboxcu.value;

			if (bc=="1"){
				b="frmcanbo.asp?Page="+cp+"&bMacu="+macu+"&bUsernamecu="+usernamecu+"&bma="+ma+"&bHoten="+hoten+"&bemail="+email
				b=b+"&bNgaysinh="+ngaysinh+"&bUsername="+username+"&bPassword="+password
				b=b+"&bLoaiCB="+nhomquyen+"&bChucdanh="+chucdanh+"&bSoNT="+sont+"&bMaDonVi="+madonvi
				b=b+"&bMailboxcu="+mailboxcu+"&bMailbox="+mailbox+"&bMailPassword="+mailpassword+"&bComm=edit"				
			}
			else
			 {
			 if (nhom.CheckAdd.checked)
			 {
				b="frmcanbo.asp?Page="+cp+"&bma="+ma+"&bHoten="+hoten+"&bemail="+email
				b=b+"&bNgaysinh="+ngaysinh+"&bUsername="+username+"&bPassword="+password
				b=b+"&bLoaiCB="+nhomquyen+"&bChucdanh="+chucdanh+"&bSoNT="+sont+"&bMaDonVi="+madonvi
				b=b+"&bMailboxcu="+mailboxcu+"&bMailbox="+mailbox+"&bMailPassword="+mailpassword+"&bComm=add"+"&bnhaplt=on"
				}
			else
			{
				b="frmcanbo.asp?Page="+cp+"&bma="+ma+"&bHoten="+hoten+"&bemail="+email
				b=b+"&bNgaysinh="+ngaysinh+"&bUsername="+username+"&bPassword="+password
				b=b+"&bLoaiCB="+nhomquyen+"&bChucdanh="+chucdanh+"&bSoNT="+sont+"&bMaDonVi="+madonvi
				b=b+"&bMailboxcu="+mailboxcu+"&bMailbox="+mailbox+"&bMailPassword="+mailpassword+"&bComm=add"+"&bnhaplt=off"
			}
			}
			window.nhom.target="right";
			window.nhom.action=b;
			window.nhom.submit();
/*			
		if (nhomquyen=="snhieunhom")
		{
			//window.nhom.target="main";
			window.nhom.target="right";
			parent.vbalFrameset.cols = "0,6,*";
			window.nhom.action="UserNhom/frmUserNhom.asp";
			window.nhom.submit();
			}
*/		
		}
}
function CmdLoc_onclick() {
	Unlockdata();
	nhom.TxtMa.focus();
}

function CmdRefresh_onclick() {
	cp=nhom.cPage.value;
	lnk="frmcanbo.asp?Page="+cp;
	window.navigate(lnk);
}

function TxtSearch_onclick() {
}

function CmdSearch_onclick() {
	nhom.CmdAdd.disabled=true;
	nhom.CmdCancel.disabled=false;
	nhom.CmdEdit.disabled=true;
	nhom.CmdDelete.disabled=true;
	nhom.CmdLock.disabled=true;
	if (nhom.TxtHoten.disabled){
		nhom.CmdSearch.value="Tì<u>m</u>";
		Unlockdata()
		nhom.TxtMa.value="";
		nhom.TxtHoten.value="";
		nhom.TxtConfirm.value="";
		nhom.TxtEmail.value="";
		nhom.TxtNgaysinh.value="";
		nhom.TxtPassword.value="";
		nhom.TxtUsername.value="";

		//Thudientu
		nhom.TxtMailBox.value="";		
		nhom.TxtMailPassword.value="";
		nhom.TxtMailConfirm.value="";

		nhom.TxtNguoisua.value="";
		nhom.TxtSoNT.value="";
		nhom.CommboChucdanh.value="";
		nhom.CommboLoai.value="";
		Lockdata();
		nhom.TxtHoten.disabled=false;
		nhom.TxtHoten.value="";
		nhom.TxtHoten.focus();		
		return false;
	}
	value=nhom.TxtHoten.value;
	blink="frmcanbo.asp?bsearch="+value+"&bComm=search"
	window.nhom.action=blink;
	window.nhom.target="right"
	window.nhom.submit();
}
function CmdPrint_onclick() {
	window.nhom.target="new"	;
	window.nhom.action="../in/frmPrintCanbo.asp";
	window.nhom.submit();
	window.nhom.target="right";
}

function TxtNgaysinh_onkeyup(str){
var keycode
keycode=window.event.keyCode
if (isEdit(keycode,str)){
	nhom.TxtNgaysinh.value=editdate(trim(str))
}
}

//-->
</SCRIPT>
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<body topmargin="0" leftmargin="0" bgcolor=#F8F9D9 style="font-family:Times new roman" onload="SetFocus()">
<form name="nhom" method="POST">
	<input type="hidden" name="sua" value="">
	<input type="hidden" name="Macu" value="">
	<input type="hidden" name="Usernamecu" value="">
	<input type="hidden" name="mailboxcu" value="">	
	<input type="hidden" name="cPage" value="<%=nPage%>">
	<input type="hidden" name="strURL" value="">
<p align=center><b><font FACE="Times New Roman" size="3">CẬP NHẬT CÁN BỘ</font></b>
<% if Session("bnhaplientuc")="on" then %>
	<table border="0" cellpadding="0" cellspacing="0" style="Font-family:arial;font-size:13pt;BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" width="100%" bgcolor="#BDD5D0">
		<tr>
		<% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then %>	
			<td width="13%"><Button disabled  name="CmdAdd" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><u>T</u>hêm</Button></td>
			<td width="13%"><Button disabled name="CmdDelete" style="FONT-FAMILY: Arial; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
			<td width="13%"><Button disabled name="CmdEdit" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
			<td width="13%"><Button disabled  name="CmdLock" style="FONT-FAMILY:Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdLock_onclick()" accesskey="K"><p>Bỏ <u>k</u>hóa</p></Button></td>
			<td width="13%"><Button name="CmdOK" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
			<td width="13%"><Button name="CmdCancel" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
			<td width="9%"><Button disabled name="CmdPrint" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdPrint_onclick()" accesskey="I"><p><u>I</u>n</p></Button></td>			
			<td width="13%"><Button disabled name="CmdSearch" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><p>Tì<u>m</u> kiếm</p></Button></td>	
		<%end if%>
		</tr>
	</table>
	<table border="0" cellspacing="0" style="Font-family:Times New Roman;font-size:12pt; BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" width="100%" bgcolor="#BDD5D0">
	<tr>
		<td width="15%">Mã cán bộ</td>
		<td width="36%" colspan=3>
        <input type="text" name="TxtMa" value="<%=TaoMa("macanbo","canbo")%>" maxLength=10 style="FONT-FAMILY:Arial;width:100%" size="20"></td>
		<td width="15%" align="center">E-Mail</td>
		<td width="34%" colspan=4>
        <input type="text" name="TxtEmail" maxLength=60 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
  <tr>
    <td width="15%">Họ và tên</td>
    <td width="36%" colspan=3>
    <input type="text" name="TxtHoten" maxLength=30 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="15%" align="center">Quyền</td>
    <td width="29%" colspan=3>                	
    			<select size="1" name="CommboLoai" style="font-family: Arial;width:100%">
					<option value="skhongnhom">
					<%
                	'sua doi combobox cho hien thi nhom quyen trong csdl
                	set RecNhomQuyen=server.CreateObject("ADODB.Recordset")
                	ssql= "select * from nhomquyen order by ten_nhom"
                	RecNhomQuyen.Open ssql,Conn
					if (not RecNhomQuyen.EOF) or (not RecNhomQuyen.BOF) then
                		RecNhomQuyen.MoveFirst
                			do while not RecNhomQuyen.EOF%>
                				<option value="<%=RecNhomQuyen("nhom_id")%>"><%=RecNhomQuyen("ten_nhom")%>
                				<%RecNhomQuyen.MoveNext
                			loop
                	end if
					RecNhomQuyen.Close
					set RecNhomQuyen=nothing %>
              		<option value="snhieunhom"><b>>>></b>
              	</select></td>
	<td width="5%"><input type=button name="cmdNhomQuyen" disabled=true value="..."style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdUserNhom_onclick()"></td>
  </tr>
  <tr>
    <td width="15%">Ngày sinh</td>
    <td width="36%" colspan=3>
    <input type="text" name="TxtNgaysinh" maxLength=10 style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtNgaysinh_onkeyup(this.value)" size="20"></td>
    <td width="15%" align="center">Chức danh</td>
    <td width="34%" colspan=4>                	
    			<select size="1" name="CommboChucdanh" style="font-family: Arial;width:100%">
                		<option value="">
                		<% 	Set RecT=server.CreateObject("ADODB.Recordset") 
                		ssql="Select * from chucdanh order by machucdanh"
                		RecT.Open ssql,Conn
                		if (not rect.eof )or ( not rect.BOF) then
                			rect.MoveFirst
							Do While Not RecT.eof     
							if rect("machucdanh")<>bchucdanh then	
                		%>
                			<option value="<%=RecT("Machucdanh")%>"><%=RecT("Tenchucdanh")%>
                			<%else%>
                			<option value="<%=RecT("Machucdanh")%>"><%=RecT("Tenchucdanh")%>
                			<%end if %>
                		<%	RecT.MoveNext
                			Loop
                		END IF
                		RecT.close
                		set RecT=nothing
                	%>
                	</select></td>
  </tr>
  <tr>
    <td width="15%">Giới tính</td>
    <td width="12%"><input type=radio ID=R1 checked name=RSex value=0><label for=R1 accesskey="A">N<u>a</u>m</label></td>
    <td width="12%"><input type=radio ID=R2 name=RSex value=1><label for=R2 accesskey="U">N<u>ữ</u></label></td>
    <td width="12%"><input ID=R3 type=radio name=RSex value=2><label for=R3 accesskey="N"><u>N</u>hóm</label></td>
    <td width="15%" align=center>Số nhắn tin</td>	
    <td width="34%" colspan=4>
    <input type="text" name="TxtSoNT" style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
    <tr>
	  <td width="15%" colspan=1 align="left">Đơn vị</td>
	  <td width="30%" colspan=4>                	
    			<select size="1" name="comboDonVi" style="font-family: Arial;width:100%">
	    			<%'<option value="">%>
					<%					
                	set RecDV=server.CreateObject("ADODB.Recordset")
					if IsRoot(Session("bMaDonVi")) then
						'strWhereDV= " where SUBSTRING(madonvi,5,2) like '00' "
						strWhereDV= ""
					else
						strWhereDV= " where madonvi like '"& LEFT(Session("bMaDonVi"),4) &"%' "
					end if
					ssql= "select * from DonVi " & strWhereDV & " order by madonvi"
				
                	RecDV.Open ssql,Conn
					if (not RecDV.EOF) or (not RecDV.BOF) then
                		RecDV.MoveFirst
                			do while not RecDV.EOF%>
							<% bTab=funTab(RecDV("madonvi"))%>                			
                				<option value="<%=RecDV("madonvi")%>"><% =bTab%><%=RecDV("tendonvi")%>                				
                				<%RecDV.MoveNext
                			loop
                	end if
					RecDV.Close
					set RecDV=nothing %>
              	</select></td>  
  </tr>
  <tr>
    <td width="15%" >Tên ĐN</td>
    <td width="24%" colspan="2">
    <input type="text" name="TxtUsername" maxLength=10 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
	<td width="12%" align=center>Mật khẩu</td>
    <td width="15%">
    <input type="password" name="TxtPassword" maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="18%" colspan=2 align=center>Xác nhận lại</td>
	<td width="16%" colspan=2>
    <input type="password" name="TxtConfirm" maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
  <tr>
    <td width="15%" >Hộp thư</td>
    <td width="24%" colspan="2">
    <input type="text" name="TxtMailBox" maxLength=10 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
	<td width="12%" align=center>Mật khẩu</td>
    <td width="15%">
    <input type="password" name="TxtMailPassword" maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="18%" colspan=2 align=center>Xác nhận lại</td>
	<td width="16%" colspan=2>
    <input type="password" name="TxtMailConfirm" maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>   
  <tr>
    <td width="15%">Người nhập</td>
    <td width="51%" colspan="4">
    <input type="text" name="TxtNguoisua" maxLength=30 style="FONT-FAMILY: arial;background-color:#BDD5D0;width:100%" size="20"></td>
  	<td width="18%" colspan=2 align=center><label for=C1 accesskey="h">T<u>h</u>êm liên tục</label><input type="checkbox" name="CheckAdd" value="ON" checked id=C1></td>
	<td width="16%" colspan=2></td>
  </tr>
</table>
<%else%>

<table border="0" cellpadding="0" cellspacing="0" style="Font-family:arial;font-size:13pt;BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" width="100%" bgcolor="#BDD5D0">
  <tr>
  <% if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),Session("FormName"),2)="1" or Session("IsAdmin") then %>	
    <td width="13%"><Button name="CmdAdd" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><u>T</u>hêm</Button></td>
    <%if bcomm<>"detail" then%>
		<td width="13%"><Button disabled name="CmdDelete" style="FONT-FAMILY: Arial; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
		<td width="13%"><Button disabled name="CmdEdit" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
		<td width="13%"><Button name="CmdLock" disabled style="FONT-FAMILY:Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdLock_onclick()" accesskey="K"><p>Bỏ <u>k</u>hóa</p></Button></td>
    <%else%>
		<td width="13%"><Button name="CmdDelete" style="FONT-FAMILY: Arial; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
		<td width="13%"><Button name="CmdEdit" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
			<%if bLock then%>
			<td width="13%"><Button name="CmdLock" style="FONT-FAMILY: Time New Roman; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdLock_onclick()" accesskey="K"><p>Bỏ <u>k</u>hóa</p></Button></td>
		<%else%>
			<td width="13%"><Button name="CmdLock" style="FONT-FAMILY: Time New Roman; POSITION: relative; WIDTH:100%" LANGUAGE=javascript onclick="return CmdLock_onclick()" accesskey="K"><u>K</u>hóa</Button></td>
		<%end if%>
	<%end if%>
    <td width="13%"><Button name="CmdOK" disabled=true style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
    <td width="13%"><Button name="CmdCancel" disabled=true style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
	<td width="9%"><Button name="CmdPrint" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdPrint_onclick()" accesskey="I"><p><u>I</u>n</p></Button></td>    
    <td width="13%"><Button name="CmdSearch" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><p>Tì<u>m</u> kiếm</p></Button></td>
<%else%>
	<td width="13%"><Button disabled  name="CmdAdd" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdAdd_onclick()" accesskey="T"><u>T</u>hêm</Button></td>
	<td width="13%"><Button disabled name="CmdDelete" style="FONT-FAMILY: Arial; WIDTH:100%" LANGUAGE=javascript onclick="return CmdDelete_onclick()" accesskey="X"><u>X</u>óa</Button></td>
    <td width="13%"><Button disabled name="CmdEdit" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdEdit_onclick()" accesskey="S"><u>S</u>ửa</Button></td>
    <td width="13%"><Button disabled  name="CmdLock" disabled style="FONT-FAMILY:Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdLock_onclick()" accesskey="K"><p>Bỏ <u>k</u>hóa</p></Button></td>
	<td width="13%"><Button disabled  name="CmdOK" disabled=true style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdOK_onclick()" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
    <td width="13%"><Button disabled  name="CmdCancel" disabled=true style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdCancel_onclick()" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
	<td width="9%"><Button name="CmdPrint" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdPrint_onclick()" accesskey="I"><p><u>I</u>n</p></Button></td>
    <td width="13%"><Button name="CmdSearch" style="FONT-FAMILY: Arial;WIDTH:100%" LANGUAGE=javascript onclick="return CmdSearch_onclick()" accesskey="M"><p>Tì<u>m</u> kiếm</p></Button></td>
    <%end if%>
  </tr>
</table>

<table border="0" cellspacing="0" style="Font-family:Times New Roman;font-size:12pt; BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;border-collapse:collapse; border-left-color:#C0C0C0; border-right-color:#C0C0C0; border-top-color:#C0C0C0; border-bottom-color:#C0C0C0" width="100%" bgcolor="#BDD5D0">
  <% if bcomm="detail" then %>
  <tr>
    <td width="15%">Mã cán bộ</td>
    <td width="36%" colspan=3>
    <input type="text" name="TxtMa" disabled=true value="<%=bma%>" maxLength=10 style="FONT-FAMILY:Arial;width:100%" size="20"></td>
    <td width="15%" align="center">E-Mail</td>
    <td width="34%" colspan=4>
    <input type="text" name="TxtEmail" disabled=true value="<%=bEmail%>" maxLength=60 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
  <tr>
    <td width="15%">Họ và tên</td>
    <td width="36%" colspan=3>
    <input type="text" name="TxtHoten" disabled=true value="<%=bHoten%>" maxLength=30 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="15%" align="center">Quyền</td>
    <td width="29%" colspan=3>                	
    	<select size="1" name="CommboLoai" disabled=true style="font-family: Arial;width:100%">
                		<%
                		'sua doi combobox cho hien thi nhom quyen trong csdl
                		set RecNhomQuyenLoc=server.CreateObject("ADODB.Recordset")
                		lsql= "select n.nhom_id from nhomquyen as n inner join canbo_nhomquyen as c on n.nhom_id= c.nhom_id where c.macanbo like '"& bMa &"' "
                		RecNhomQuyenLoc.CursorType=3
						RecNhomQuyenLoc.CacheSize=5
                		RecNhomQuyenLoc.Open lsql,Conn                		                		
                		if RecNhomQuyenLoc.RecordCount < 1 then %>
                			<option selected value="skhongnhom">
                				<%set RecNhomQuyen=server.CreateObject("ADODB.Recordset")
                				ssql= "select * from nhomquyen order by ten_nhom"
                				RecNhomQuyen.CursorType=3
								RecNhomQuyen.CacheSize=5
                				RecNhomQuyen.Open ssql,Conn%>
                				<%if (not RecNhomQuyen.EOF) or (not RecNhomQuyen.BOF) then
                					RecNhomQuyen.MoveFirst
                					do while not RecNhomQuyen.EOF%>
                						<option value="<%=RecNhomQuyen("nhom_id")%>"><%=RecNhomQuyen("ten_nhom")%>
                					<%RecNhomQuyen.MoveNext
                					loop
                				end if
                				RecNhomQuyen.Close
                				set RecNhomQuyen=nothing %>
                			<option value="snhieunhom"><b>>>></b>
                		<%else
                			
                			if RecNhomQuyenLoc.RecordCount=1 then%>
                				<option value="skhongnhom">
                				<%set RecNhomQuyen=server.CreateObject("ADODB.Recordset")
                				ssql= "select * from nhomquyen order by ten_nhom"
                				RecNhomQuyen.Open ssql,Conn%>
                				<%if (not RecNhomQuyen.EOF) or (not RecNhomQuyen.BOF) then
                					RecNhomQuyen.MoveFirst
                					do while not RecNhomQuyen.EOF
                						if RecNhomQuyen("nhom_id") = RecNhomQuyenLoc("nhom_id") then%>
                							<option selected value="<%=RecNhomQuyen("nhom_id")%>"><%=RecNhomQuyen("ten_nhom")%>
                						<% else %>
                							<option value="<%=RecNhomQuyen("nhom_id")%>"><%=RecNhomQuyen("ten_nhom")%>
                						<%end if
                						RecNhomQuyen.MoveNext
                					loop
                				end if
                				RecNhomQuyen.Close
                				set RecNhomQuyen=nothing %>
                			<option value="snhieunhom"><b>>>></b>
                			<%else%>
                			
                			<option value="skhongnhom">
                				<%set RecNhomQuyen=server.CreateObject("ADODB.Recordset")
                				ssql= "select * from nhomquyen order by ten_nhom"
                				RecNhomQuyen.Open ssql,Conn%>
                				<%if (not RecNhomQuyen.EOF) or (not RecNhomQuyen.BOF) then
                					RecNhomQuyen.MoveFirst
                					do while not RecNhomQuyen.EOF%>
                						<option value="<%=RecNhomQuyen("nhom_id")%>"><%=RecNhomQuyen("ten_nhom")%>
                					<%RecNhomQuyen.MoveNext
                					loop
                				end if
                				RecNhomQuyen.Close
                				set RecNhomQuyen=nothing %>
                			<option selected value="snhieunhom"><b>>>></b>
                			
                			<%end if%>
                	                		
                	<%end if
              	RecNhomQuyenLoc.Close
              	set RecNhomQuyenLoc=nothing%>
              	</select></td>
	<td width="5%"><input type=button name="cmdNhomQuyen" disabled=true value="..."style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdUserNhom_onclick()"></td>
  </tr>
  <tr>
    <td width="15%">Ngày sinh</td>
    <td width="36%" colspan=3>
    <input type="text" name="TxtNgaysinh" disabled=true value="<%=ClsFun.FormatDate(bngaysinh)%>" maxLength=10 style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtNgaysinh_onkeyup(this.value)" size="20"></td>
    <td width="15%" align="center">Chức danh</td>
    <td width="34%" colspan=4>                	
    			<select size="1" name="CommboChucdanh" disabled=true style="font-family: Arial;width:100%">
                	<option selected value="">
                		<% 	Set RecT=server.CreateObject("ADODB.Recordset") 
                		ssql="Select * from chucdanh order by machucdanh"
                		RecT.Open ssql,Conn
                		if (not rect.eof )or ( not rect.BOF) then
                			rect.MoveFirst
							Do While Not RecT.eof     
							if rect("machucdanh")<>bchucdanh then	
                		%>
                			<option value="<%=RecT("Machucdanh")%>"><%=RecT("Tenchucdanh")%>
                			<%else%>
                			<option selected value="<%=RecT("Machucdanh")%>"><%=RecT("Tenchucdanh")%>
                			<%end if %>
                		<%	RecT.MoveNext
                			Loop
                		END IF
                		RecT.close
                		set RecT=nothing
                	%>
                	</select></td>
  </tr>
  <tr>
    <td width="15%">Giới tính</td>
    <%if RSex=0 then%>
	    <td width="12%"><input type=radio ID=R1 disabled checked name=RSex value=0><label for=R1 accesskey="a">N<u>a</u>m</label></td>
    <%else%>
		<td width="12%"><input type=radio ID=R1 disabled name=RSex value=0><label for=R1 accesskey="a">N<u>a</u>m</label></td>
    <%end if%>
    <%if RSex=1 then%>
	    <td width="12%"><input type=radio ID=R2 disabled checked name=RSex value=1><label for=R2 accesskey="u">N<u>ữ</u></label></td>
    <%else%>
		<td width="12%"><input type=radio ID=R2 disabled name=RSex value=1><label for=R2 accesskey="u">N<u>ữ</u></label></td>
    <%end if%>
    <%if RSex=2 then%>
	    <td width="12%"><input ID=R3 type=radio disabled name=RSex checked value=2><label for=R3 accesskey="n"><u>N</u>hóm</label></td>
    <%else%>
		<td width="12%"><input ID=R3 type=radio disabled name=RSex value=2><label for=R3 accesskey="n"><u>N</u>hóm</label></td>
    <%end if%>
    <td width="15%" align=center>Số nhắn tin</td>
    <td width="34%" colspan=4>
    <input type="text" name="TxtSoNT" value="<%=bSoNT%>" disabled=true style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
  
  <tr>
  	<td width="15%" colspan=1 align="left">Đơn vị</td>  	
	  <td width="30%" colspan=4>                	
    			<select size="1" name="comboDonVi" disabled=true style="font-family: Arial;width:100%">
	    			<%'<option value="">%>
					<%					
                	set RecDV=server.CreateObject("ADODB.Recordset")
					if IsRoot(Session("bMaDonVi")) then
						'strWhereDV= " where SUBSTRING(madonvi,5,2) like '00' "
						strWhereDV= ""
					else
						strWhereDV= " where madonvi like '"& LEFT(Session("bMaDonVi"),4) &"%' "
					end if
					ssql= "select * from donvi " & strWhereDV & " order by madonvi"           	
					
                	RecDV.Open ssql,Conn
					if (not RecDV.EOF) or (not RecDV.BOF) then
                		RecDV.MoveFirst
                			do while not RecDV.EOF%>		                			
							<% bTab=funTab(RecDV("madonvi"))%>
							<% if RecDV("madonvi")=bMaDonVi then%>
								<option selected value="<%=RecDV("madonvi")%>"><% =bTab%><%=RecDV("tendonvi")%>
							<% else %>                			
                					<option value="<%=RecDV("madonvi")%>"><% =bTab%><%=RecDV("tendonvi")%>
                				<% end if %>
                				
                				<%RecDV.MoveNext
                			loop
                	end if
					RecDV.Close
					set RecDV=nothing %>
              	</select></td>  	
  </tr> 
    
  <tr>
    <td width="15%">Tên ĐN</td>
    <td width="24%" colspan="2">
    <input type="text" name="TxtUsername" disabled=true value="<%=busername%>" maxLength=10 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
	<td width="12%" align=center>Mật khẩu</td>
    <td width="15%">
    <input type="password" name="TxtPassword" disabled=true value="<%=bPassword%>" maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="18%" colspan=2 align=center>Xác nhận lại</td>
	<td width="16%" colspan=2>
    <input type="password" name="TxtConfirm" disabled=true value="<%=bConfirm%>" maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
  <tr>
    <td width="15%">Hộp thư</td>
    <td width="24%" colspan="2">
    <input type="text" name="TxtMailBox" disabled=true value="<%=bMailBox%>" maxLength=10 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
	<td width="12%" align=center>Mật khẩu</td>
    <td width="15%">
    <input type="password" name="TxtMailPassword" disabled=true value="<%=bMailPassword%>" maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="18%" colspan=2 align=center>Xác nhận lại</td>
	<td width="16%" colspan=2>
    <input type="password" name="TxtMailConfirm" disabled=true value="<%=bMailConfirm%>" maxLength=20  style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
  <tr>
    <td width="15%">Người nhập</td>
    <td width="51%" colspan="4">
    <input type="text" name="TxtNguoisua" disabled=true value="<%=bNguoisua%>" maxLength=30 style="FONT-FAMILY: arial;background-color:#BDD5D0;width:100%" size="20"></td>
  	<td width="18%" colspan=2 align=center><label for=C1 accesskey="h">T<u>h</u>êm liên tục</label><input type="checkbox" name="CheckAdd" value="ON" disabled=true id=C1></td>
	<td width="16%" colspan=2></td>
  </tr>
  <%else%>
  <tr>
    <td width="15%">Mã cán bộ</td>
    <td width="36%" colspan=3>
    <input type="text" name="TxtMa" disabled=true maxLength=10 style="FONT-FAMILY:Arial;width:100%" size="20"></td>

    <td width="15%" align="center">E-Mail</td>
    <td width="34%" colspan=4>
    <input type="text" name="TxtEmail" disabled=true maxLength=60 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    
  </tr>
  <tr>
    <td width="15%">Họ và tên</td>
    <td width="36%" colspan=3>
    <input type="text" name="TxtHoten" disabled=true maxLength=30 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="15%" align="center">Quyền</td>
    <td width="29%" colspan=3>
    			<select size="1" name="CommboLoai" disabled=true style="font-family: Arial;width:100%">
					<option value="skhongnhom">
					<%
                	'sua doi combobox cho hien thi nhom quyen trong csdl
                	set RecNhomQuyen=server.CreateObject("ADODB.Recordset")
                	ssql= "select * from nhomquyen order by ten_nhom"
                	RecNhomQuyen.Open ssql,Conn
					if (not RecNhomQuyen.EOF) or (not RecNhomQuyen.BOF) then
                		RecNhomQuyen.MoveFirst
                			do while not RecNhomQuyen.EOF%>
                				<option value="<%=RecNhomQuyen("nhom_id")%>"><%=RecNhomQuyen("ten_nhom")%>
                				<%RecNhomQuyen.MoveNext
                			loop
                	end if
					RecNhomQuyen.Close
					set RecNhomQuyen=nothing %>
              		<option value="snhieunhom"><b>>>></b>
              	</select></td>
	<td width="5%"><input type=button name="cmdNhomQuyen" disabled=true value="..."style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onclick="return CmdUserNhom_onclick()"></td>
  </tr>
  <tr>
    <td width="15%">Ngày sinh</td>
    <td width="36%" colspan=3>
    <input type="text" name="TxtNgaysinh" disabled=true maxLength=10 style="FONT-FAMILY: Arial;width:100%" LANGUAGE=javascript onkeyup="return TxtNgaysinh_onkeyup(this.value)" size="20"></td>
    <td width="15%" align="center">Chức danh</td>
    <td width="34%" colspan=4>                	
   			<select size="1" name="CommboChucdanh" disabled=true style="font-family: Arial;width:100%">
                		<option selected value="">
                		<% 	Set RecT=server.CreateObject("ADODB.Recordset") 
                		ssql="Select * from chucdanh order by machucdanh"
                		RecT.Open ssql,Conn
                		if (not rect.eof )or ( not rect.BOF) then
                			rect.MoveFirst
							Do While Not RecT.eof     
							if rect("machucdanh")<>bchucdanh then	
                		%>
                			<option value="<%=RecT("Machucdanh")%>"><%=RecT("Tenchucdanh")%>
                			<%else%>
                			<option value="<%=RecT("Machucdanh")%>"><%=RecT("Tenchucdanh")%>
                			<%end if %>
                		<%	RecT.MoveNext
                			Loop
                		END IF
                		RecT.close
                		set RecT=nothing
                	%>
                	</select></td>
  </tr>
  <tr>
    <td width="15%">Giới tính</td>
    <td width="12%"><input type=radio ID=R1 disabled checked name=RSex value=0><label for=R1 accesskey="a">N<u>a</u>m</label></td>
    <td width="12%"><input type=radio ID=R2 disabled name=RSex value=1><label for=R2 accesskey="u">N<u>ữ</u></label></td>
    <td width="12%"><input type=radio ID=R3 disabled name=RSex value=2><label for=R3 accesskey="n"><u>N</u>hóm</label></td>
    <td width="15%" align=center>Số nhắn tin</td>
    <td width="34%" colspan=4> 
    <input type="text" name="TxtSoNT" value="<%=bSoNT%>" disabled=true style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
  
  <tr>
	  <td width="15%" colspan=1 align="left">Đơn vị</td>
	  <td width="30%" colspan=4>                	
    			<select size="1" name="comboDonVi" disabled=true style="font-family: Arial;width:100%">
	    			<%'<option value="">%>
					<%					
                	set RecDV=server.CreateObject("ADODB.Recordset")
					if IsRoot(Session("bMaDonVi")) then
						'strWhereDV= " where SUBSTRING(madonvi,5,2) like '00' "
						strWhereDV= ""
					else
						strWhereDV= " where madonvi like '"& LEFT(Session("bMaDonVi"),4) &"%' "
					end if
					ssql= "select * from donvi " & strWhereDV & " order by madonvi"

                	RecDV.Open ssql,Conn
					if (not RecDV.EOF) or (not RecDV.BOF) then
                		RecDV.MoveFirst
                			do while not RecDV.EOF%>
							<% bTab=funTab(RecDV("madonvi"))%>                			
                				<option value="<%=RecDV("madonvi")%>"><% =bTab%><%=RecDV("tendonvi")%>                				
                				<%RecDV.MoveNext
                			loop
	                end if
					RecDV.Close
					set RecDV=nothing %>
              	</select></td>  
  </tr>
  
  <tr>
    <td width="15%" >Tên ĐN</td>
    <td width="24%" colspan="2">
    <input type="text" name="TxtUsername" disabled=true maxLength=10 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
	<td width="12%" align=center>Mật khẩu</td>
    <td width="15%">
    <input type="password" name="TxtPassword" disabled=true maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="18%" colspan=2 align=center>Xác nhận lại</td>
	<td width="16%" colspan=2>
    <input type="password" name="TxtConfirm" disabled=true maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>
  <tr>
    <td width="15%" >Hộp thư</td>
    <td width="24%" colspan="2">
    <input type="text" name="TxtMailBox" disabled=true maxLength=10 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
	<td width="12%" align=center>Mật khẩu</td>
    <td width="15%">
    <input type="password" name="TxtMailPassword" disabled=true maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
    <td width="18%" colspan=2 align=center>Xác nhận lại</td>
	<td width="16%" colspan=2>
    <input type="password" name="TxtMailConfirm" disabled=true maxLength=20 style="FONT-FAMILY: Arial;width:100%" size="20"></td>
  </tr>    
  <tr>
    <td width="15%">Người nhập</td>
    <td width="51%" colspan="4">
    <input type="text" name="TxtNguoisua" disabled=true maxLength=30 style="FONT-FAMILY: arial;background-color:#BDD5D0;width:100%" size="20"></td>
  	<td width="18%" colspan=2 align=center><label for=C1 accesskey="h">T<u>h</u>êm liên tục</label><input type="checkbox" name="CheckAdd" value="ON" disabled=true id=C1></td>
	<td width="16%" colspan=2></td>
  </tr>
  <%end if%>
</table>
<%end if%>
<!-- Danh sach can bo -->
<table border="0" style="Font-family:Times new roman;font-size:12pt; BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;Border-color:#C0C0C0" WIDTH= "100%" cellspacing=1 cellpadding=1>
  <tr>
    <td width="100%" colspan="3" bgcolor="#173584"><p align="center"><b><font color="#FFFFFF" size="2">DANH SÁCH CÁN BỘ</font></b></td>
  </tr>
  <tr bgcolor="#BDD5D0">
    <td width="15%" align="center"><b>Mã</b></td>
    <td width="320" align="center"><b>Tên cán bộ</b></td>
    <td width="35%" align="center"><b>E-Mail</b></td>
  </tr>
  	<%	
	If Not Rec.Eof Then
		nRecCount = Rec.RecordCount
		Rec.PageSize = 20
		nPageCount = Rec.PageCount
		If nPage < 1 then
			nPage = 1			
		End If
		if nPage > nPageCount Then
			nPage=nPageCount
		end if
		cnt=(pg-1)*pgsize + 1		    
		STT=1
		rec.AbsolutePage=nPage
		howmanyrecs=0
		do while not Rec.EOF and howmanyrecs<rec.PageSize
			if (cnt/2=int(cnt/2)) then
				color="#eeeecc"
			else
				color="#F8F9D9"
			end if
			if Rec("Lock") then
				bcolor="#C0C0C0"
			else
				bcolor="blue"
			end if
%>
			<tr id=mnu_<%=STT%> style="BORDER-RIGHT: #e7e7e7 1px solid; BORDER-TOP: #e7e7e7 1px solid; BORDER-LEFT: #e7e7e7 1px solid; COLOR: #666666; BORDER-BOTTOM: #e7e7e7 1px solid; HEIGHT: 21px; BACKGROUND-COLOR: <%=color%>" 				onmouseover="javascript:MouseOverMenu('mnu_<%=STT%>')" onmouseout="javascript:MouseOutMenu('mnu_<%=STT%>','<%=color%>')">
				  <td width="15%" height="1"><a onmouseout="window.status='';return true" onmouseover="window.status='Ch&#7885;n th&#244;ng tin';return true" style='cursor:hand;color:<%=bColor%>;text-decoration: none' href="frmcanbo.asp?bnhaplt=<%="off"%>&page=<%=nPage%>&bma=<%=Rec("Macanbo")%>&bComm=<%="detail"%>&amp;RSex=<%=rec("Gioitinh")%>"><%=Rec("Macanbo")%></a></td>
				  <td width="50%" height="1"><a onmouseout="window.status='';return true" onmouseover="window.status='Ch&#7885;n th&#244;ng tin';return true" style='cursor:hand;color:<%=bColor%>;text-decoration: none' href="frmcanbo.asp?bnhaplt=<%="off"%>&page=<%=nPage%>&bma=<%=Rec("Macanbo")%>&bComm=<%="detail"%>&amp;RSex=<%=rec("Gioitinh")%>"><%=Rec("Hovaten")%></a></td>
				  <td width="35%" height="1"><a onmouseout="window.status='';return true" onmouseover="window.status='Ch&#7885;n th&#244;ng tin';return true" style='cursor:hand;color:<%=bColor%>;text-decoration: none' href="frmcanbo.asp?bnhaplt=<%="off"%>&page=<%=nPage%>&bma=<%=Rec("Macanbo")%>&bComm=<%="detail"%>&amp;RSex=<%=rec("Gioitinh")%>"><%=Rec("email")%></a></td> 
			</tr>
<%			STT=STT+1
			Rec.MoveNext
			cnt=cnt+1
			howmanyrecs=howmanyrecs+1
		loop
	end if
	rec.Close
	set rec=nothing
	
%>  
  </TR>
</table>

 <!-- Phan trang -->
<br>
<table width="98%" cellspacing=0 cellpadding=0>
<tr>
<% if nPage > 0 and nPageCount >0  then %>  
	<td width="20%"><b>Trang&nbsp; <%=nPage%>/<%=nPageCount%></b></td>
<!-- 	<td width= "80%" align="right">
	<% if nPageCount > 1 then %>    
		Chuyển nhanh tới trang:&nbsp;
		<select name="page" style="width:45;height:23;font-size:8pt" size=1 onchange="javaScript:ChangePage()">
			<% for i = 1 to nPageCount%>	
				<% if bComm<>"search"  then
						strURL="frmcanbo.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm="
					else
						strURL="frmcanbo.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm=search"
					end if %>
				<option value="<%=strURL%>" <%=chkSelected(i, nPage)%>><%=i%></option>
			<% next %>    
		</select>
		</td>                                  
	<% end if %> -->             
<% 'else %>
<% end if %>
<td width= "80%" align="center"><%=Paging(nPage, nPageCount, nRecCount)%></td>
  </tr>
</table>
</body>
</form>
</html>
<%
	Conn.Close
	Set Conn=nothing
	set ClsFun=nothing
%>